package com.zhiteng.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiteng.entity.SysDict;
import com.zhiteng.mapper.SysDictMapper;
import com.zhiteng.service.SysDictService;

@Service
public class SysDictServiceImpl implements SysDictService {

	@Autowired
	private SysDictMapper sysDictMapper;

	/*@Override
	public List<String> queryAdjustDict(String schoolId) {
		SysDict record = new SysDict();
		record.setType("adjust");
		record.setSchoolId(schoolId);
		List<SysDict> list = sysDictMapper.select(record);
		List<String> list2 = new ArrayList<>();
		for (SysDict SysDict : list) {
			list2.add(SysDict.getLabel());
		}
		return list2;
	}*/

	@Override
	public List<SysDict> queryDictBySchoolId(String schoolId) {
		SysDict dict = new SysDict();
		dict.setSchoolId(schoolId);
		return sysDictMapper.select(dict);
	}
	
	@Override
	public List<SysDict> queryDictBySchoolIdAndType(String schoolId, String type) {
		SysDict dict = new SysDict();
		dict.setSchoolId(schoolId);
		dict.setType(type);
		return sysDictMapper.select(dict);
	}

	@Override
	public int saveDict(SysDict dict) {
		return sysDictMapper.insert(dict);
	}

	@Override
	public int deleteDictById(SysDict dict) {
		return sysDictMapper.delete(dict);
	}

/*	@Override
	public List<SysDict> queryDictsBySchoolId(String schoolId) {
		Example example = new Example(SysDict.class);
		Criteria criteria = example.createCriteria();
		criteria.andEqualTo("schoolId", schoolId);
		criteria.orEqualTo("label", "take");
		criteria.orEqualTo("label", "adjust");
		criteria.orEqualTo("label", "leave");
		return sysDictMapper.selectByExample(example);
	}*/
	
	//////////////////////////////////////////////////////
	@Override
	public List<SysDict> queryAdjustDict(String schoolId) {
		SysDict record = new SysDict();
		record.setType("adjust");
		record.setSchoolId(schoolId);
		List<SysDict> list = sysDictMapper.select(record);
//		List<String> list2 = new ArrayList<>();
//		for (SysDict SysDict : list) {
//			list2.add(SysDict.getLabel());
//		}
		return list;
	}

	@Override
	public List<SysDict> querySysDict(String schoolId) {
		SysDict record = new SysDict();
		record.setType("take");
		record.setSchoolId(schoolId);
		List<SysDict> list = sysDictMapper.select(record);
		return list;
	}


	
}
